<?php
namespace App\Api\Controllers\EasyPay;

use GuzzleHttp\Client;

final class Payment
{

    function __construct($url)
    {
        $this->url = $url;
        $this->http = new Client();
    }


    public function request($params, $key)
    {
        $params = array_filter($params);
        $signature = new Signature($key);
        $params['sign'] = $signature->sign($params);

        $response = $this->http->request('POST', $this->url, [
            'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
            'form_params' => $params
        ]);

        return (string) $response->getBody();
    }


}
